package dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import dao.CategoryDao;
import entity.Category;

public class CategoryDaoImpl extends BaseDaoImpl<Category> implements CategoryDao {

	@Override
	public List<Category> getCategory() {
		String sql = "SELECT * FROM Category";
		return showAll(sql);
	}

	@Override
	public List<Category> listByRs(ResultSet rs) {
		List<Category> list =new ArrayList<Category>();
		try {
			while(rs.next()){
				list.add(new Category(rs.getInt("id"),rs.getString("name")));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}


}
